package org.michaelrenaud.pathfinder.shared.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Stat implements Serializable {

	private static final long serialVersionUID = -832184313502617186L;
	private String name = "";
	private int base = 0;
	private List<HasEffects> effectContainers = new ArrayList<HasEffects>();

	public Stat() {
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setEffectContainers(List<HasEffects> effectContainers) {
		this.effectContainers = effectContainers;
	}

	public String getName() {
		return name;
	}

	public List<HasEffects> getEffectContainers() {
		return effectContainers;
	}

	public int getBase() {
		return base;
	}

	public void setBase(int base) {
		this.base = base;
	}
	
	public int getTotal() {
		int total = base;
		for(HasEffects effectContainer : effectContainers) {
			total += effectContainer.getEffect(name).getModification();
		}
		return total;
	}
	
	public String getTooltip() {
		String tooltip = "";
		if(base > 0)
			tooltip += "Base: " + base + "\n";
		for(HasEffects effectContainer : effectContainers) {
			tooltip += effectContainer.getName() + "\n";
			tooltip += " -" + effectContainer.getShortDescription() + "\n";
		}
		return tooltip;
	}
}
